@extends('layouts.app')
@section('title',isset($category) ? $category->name : '话题列表')
@section('content')
<div class="container">
    <div class="col-md-10 col-md-offset-1">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h1>
                    <i class="glyphicon glyphicon-align-justify"></i> Topic
                    <a class="btn btn-success pull-right" href="{{ route('topics.create') }}"><i class="glyphicon glyphicon-plus"></i> Create</a>
                </h1>
            </div>

            <div class="panel-body">
                <div class="col-lg-9 col-md-9 topic-list">
                    @if(isset($category))
                        <div class="alert alert-info" role="alert">
                            {{ $category->name }} : {{$category -> description}}
                        </div>
                    @endif
                    <div class="panel panel-default">

                        <div class="panel-heading">
                            <ul class="nav nav-pills">
                                <li class="{{ active_class( ! if_query('order', 'recent') ) }}"><a href="{{ Request::url() }}?order=default">最后回复</a></li>
                                <li class="{{ active_class(if_query('order', 'recent')) }}"><a href="{{ Request::url() }}?order=recent">最新发布</a></li>
                            </ul>
                        </div>

                        <div class="panel-body">
                            {{-- 话题列表 --}}
                            @include('topics._topic_list', ['topics' => $topics])
                            {{-- 分页 --}}
                            {!! $topics->appends(Request::except('page'))->render() !!}
                        </div>
                    </div>
                </div>

                <div class="col-lg-3 col-md-3 sidebar">
                    @include('topics._sidebar')
                </div>
            </div>
        </div>
    </div>
</div>

@endsection